package cn.edu.tju.elm.repository;

import cn.edu.tju.elm.model.Cart;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
import java.util.List;

public interface CartRepository extends JpaRepository<Cart, Long> {

    /**
     * 根据顾客ID和菜品ID查找购物车项
     */
    Optional<Cart> findByCustomerIdAndFoodId(Long customerId, Long foodId);


    // 根据用户ID和商家ID查找购物车项
    List<Cart> findByCustomerIdAndBusinessId(Long customerId, Long businessId);
    // 根据用户ID和商家ID删除购物车项
    void deleteByCustomerIdAndBusinessId(Long customerId, Long businessId);

    /**
     * 根据顾客ID查找所有购物车项
     */
    List<Cart> findByCustomerId(Long customerId);
}
